package thinkingJava.chapter15;

import java.util.Date;

interface TimeStamped {
	long getStamp();
}
class TimeStampedImpl implements TimeStamped {
	private final long timestamp;
	public TimeStampedImpl() {
		timestamp = (new Date()).getTime();
	}
	public long getStamp() {
		return timestamp;
	}
}
interface SerialNumbered {
	long getSerialNumber();
}
class SerialNumberedImpl implements SerialNumbered {
	private static long counter = 1;
	private final long serialNumber = counter++;
	public long getSerialNumber() {
		return serialNumber;
	}
}
interface Basic {
	public void set(String arg);
	public String get();
}
class BasicImpl implements Basic {
	private String value;
	public void set(String val) {
		this.value = val;
	}
	public String get() {
		return value;
	}
}
class Mixin extends BasicImpl implements TimeStamped, SerialNumbered {
	private TimeStamped timeStampImp = new TimeStampedImpl();
	private SerialNumbered serialNumberImp = new SerialNumberedImpl();
	public long getSerialNumber() {
		return serialNumberImp.getSerialNumber();
	}
	public long getStamp() {
		return timeStampImp.getStamp();
	}
}
public class Mixins {
	public static void main(String[] args) {
		Mixin mix1 = new Mixin(), mix2 = new Mixin();
		mix1.set("test string 1");
		mix2.set("test string 2");
		System.out.println(mix1.get() + " " + mix1.getSerialNumber() + " " + mix1.getStamp());
		System.out.println(mix2.get() + " " + mix2.getSerialNumber() + " " + mix2.getStamp());
	}
}
